home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvitops / dvitops.pro < prev    next >
Text File  |  1991-01-25  |  6KB  |  310 lines

  1. %!
  2. % $Header: /usr/jjc/dvitops/RCS/dvitops.pro,v 1.4 90/03/12 18:44:05 jjc Rel $
  3.  
  4. /dvitops 200 dict def dvitops begin
  5.  
  6. systemdict /setpacking known {
  7.     /savepacking currentpacking def
  8.     true setpacking
  9. } if
  10.  
  11. % <h> <v> <string> Z
  12. /Z {
  13.     3 1 roll moveto show
  14. } bind def
  15.  
  16. % <h> <string> X
  17. /X {
  18.     exch currentpoint exch pop moveto show
  19. } bind def
  20.  
  21. % <rh> <string> W
  22. /W {
  23.     exch 0 rmoveto show
  24. } bind def
  25.  
  26. /M /moveto load def
  27.  
  28. % When PostScript fills a path, it seems to blacken any pixel that
  29. % wholly ***or partly*** lies within the path. Thus we can achieve
  30. % results predictable down to the pixel level by ensuring that
  31. % the corners of the rule do ***not*** lie on pixel boundaries.
  32. % This procedure is made more complex by the fact that we do
  33. % not know what the orientation of device space is---it cannot be
  34. % assumed to be same as the default user coordinate system.
  35. % This procedure assumes that the height and width are both > 0.
  36. % height width x y R
  37. /R {
  38.     newpath
  39.     % transform the coordinates of the bottom left hand corner
  40.     % to device space and round them to the nearest pixel
  41.     transform round exch round exch
  42.     % compute and moveto the point half a pixel up from and half a pixel to the
  43.     % right of this position
  44.     .5 .5 idtransform abs neg exch abs exch dtransform
  45.     3 -1 roll add 3 1 roll add exch itransform moveto
  46.     % compute the height and width of the rule
  47.     exch dtransform abs ceiling 1 sub exch abs ceiling 1 sub exch idtransform
  48.     abs exch abs exch
  49.     % draw the rule
  50.     dup 0 exch neg rlineto exch 0 rlineto 0 exch rlineto fill
  51. } bind def
  52.  
  53.  
  54. /BP {
  55.     /level0 save def
  56. } bind def
  57.  
  58. /EP {
  59.     level0 restore showpage
  60. } bind def
  61.  
  62. /BO {
  63.     /level1 save def
  64. } bind def
  65.  
  66. /EO {
  67.     level1 restore
  68. } bind def
  69.  
  70.  
  71. % <page width> landscape
  72. % page width is in PostScript points
  73.  
  74. /landscape {
  75.     /pw exch def
  76.     [0 1 -1 0 pw 0] concat
  77. } def
  78.  
  79.  
  80. % <num> <den> <mag> <hoffset> <voffset> <page height> SC
  81. % hoffset and voffset are in PostScript points
  82. % page height is in PostScript points
  83.  
  84. /SC {
  85.     /ph exch def
  86.     /voffset exch def
  87.     /hoffset exch def
  88.     /mag exch def
  89.     /den exch def
  90.     /num exch def
  91.     0 ph translate 1 -1 scale
  92.     hoffset voffset translate
  93.     num 254000 div 72 mul den div mag mul 1000 div dup scale
  94. } bind def
  95.  
  96.  
  97.  
  98. /FF {
  99.     findfont def
  100. } bind def
  101.  
  102. /SF {
  103.     /a exch def
  104.     [a 0 0 a neg 0 0] makefont def
  105. } bind def
  106.  
  107. /F /setfont load def
  108.  
  109. % newdictname newfontname newencoding basefontdict RE -
  110. /RE {
  111.     dup maxlength dict /f exch def
  112.     {
  113.         exch dup dup /FID ne exch /Encoding ne and {
  114.             exch f 3 1 roll put
  115.         } {
  116.             pop pop
  117.         } ifelse
  118.     } forall
  119.     f /Encoding 3 -1 roll put
  120.     dup f /FontName 3 -1 roll put
  121.     f definefont def
  122. } bind def
  123.  
  124. %<string> <start index> makelong
  125. /makelong {
  126.     /i exch def
  127.     /s exch def
  128.     s i get 24 bitshift
  129.     s i 1 add get 16 bitshift or
  130.     s i 2 add get 8 bitshift or
  131.     s i 3 add get or
  132. } bind def
  133.  
  134. /BuildPK {
  135.     /char exch def
  136.     /fontdict exch def
  137.     /charname
  138.         fontdict /Encoding get char get
  139.     def
  140.     /charinfo
  141.         fontdict /CharData get charname get
  142.     def
  143.     /flag 
  144.         charinfo 0 get
  145.     def
  146.     flag 0 eq {
  147.         /dm charinfo 1 get def
  148.         /dn 0 def
  149.         /cols charinfo 2 get def
  150.         /rows charinfo 3 get def
  151.         /hoff
  152.             charinfo 4 get
  153.             dup 127 gt {
  154.                 256 sub
  155.             } if
  156.         def
  157.         /voff
  158.             charinfo 5 get
  159.             dup 127 gt {
  160.                 256 sub
  161.             } if
  162.         def
  163.         /prelen 6 def
  164.     } {
  165.         flag 1 eq {
  166.             /dm charinfo 1 get 256 mul charinfo 2 get add def
  167.             /dn 0 def
  168.             /cols charinfo 3 get 256 mul charinfo 4 get add def
  169.             /rows charinfo 5 get 256 mul charinfo 6 get add def
  170.             /hoff
  171.                 charinfo 7 get 256 mul charinfo 8 get add
  172.                 dup 32767 gt {
  173.                     65536 sub
  174.                 } if
  175.             def
  176.             /voff
  177.                 charinfo 9 get 256 mul charinfo 10 get add
  178.                 dup 32767 gt {
  179.                     65536 sub
  180.                 } if
  181.             def
  182.             /prelen 11 def
  183.         } {
  184.             /dm charinfo 1 makelong 65536 div def
  185.             /dn charinfo 5 makelong 65536 div def
  186.             /cols charinfo 9 makelong def
  187.             /rows charinfo 13 makelong def
  188.             /hoff charinfo 17 makelong def
  189.             /voff charinfo 21 makelong def
  190.             /prelen 25 def
  191.         } ifelse
  192.     } ifelse
  193.     /llx hoff neg .5 sub def
  194.     /lly voff 1 add rows sub .5 add def
  195.     dm dn llx lly llx cols add lly rows add setcachedevice
  196.     cols
  197.     rows
  198.     true
  199.     fontdict /ImageMaskMatrix get dup 4 llx neg put    dup 5 rows lly add put
  200.     {
  201.         charinfo prelen charinfo length prelen sub getinterval
  202.     }
  203.     imagemask
  204. } bind def
  205.  
  206.  
  207. /EmptyEncoding 256 array def 0 1 255 {EmptyEncoding exch /.notdef put} for
  208.  
  209. % <name> <ds> <hppp> <vppp> <encoding> <CharData> <llx> <lly> <urx> <ury>
  210. /DefinePKFont {
  211.     4 array astore /bbox exch def
  212.     /data exch def
  213.     /encoding exch def
  214.     /vppp exch def
  215.     /hppp exch def
  216.     /ds exch def
  217.  
  218.     9 dict dup begin
  219.         /FontType 3 def
  220.         /Encoding encoding def
  221.         /BuildChar /BuildPK load def
  222.         /ImageMaskMatrix [1 0 0 -1 0 0] def
  223.         /FontMatrix [
  224.             65536 ds 1048576 div hppp mul div
  225.             0
  226.             0
  227.             65536 ds 1048576 div vppp mul div
  228.             0
  229.             0
  230.         ] def
  231.         /FontBBox bbox def
  232.         /CharData data def
  233.         CharData /.notdef <000000000000> put
  234.     end
  235.     definefont pop
  236. } def
  237.  
  238. % this comes from the Adobe Ilustrator manual
  239.  
  240. /Locate {
  241.     8 dict begin
  242.     [/newury /newurx /newlly /newllx /ury /urx /lly /llx]
  243.     {
  244.         exch def
  245.     } forall
  246.     newllx newlly translate
  247.     newurx newllx sub urx llx sub div
  248.     newury newlly sub ury lly sub div
  249.     scale
  250.     llx neg lly neg translate
  251.     end
  252. } bind def
  253.  
  254. % tpic stuff
  255.  
  256. /MT {
  257.     transform round exch round exch itransform
  258.     moveto
  259. } bind def
  260.  
  261. /LT {
  262.     transform round exch round exch itransform
  263.     lineto
  264. } bind def
  265.  
  266. /CT {
  267.     transform round exch round exch itransform
  268.     curveto
  269. } bind def
  270.  
  271. /ST /stroke load def
  272. /FI /fill load def
  273. /CP /closepath load def
  274. /SG /setgray load def
  275. /LW /setlinewidth load def
  276. /GR /grestore load def
  277. /GS /gsave load def
  278.  
  279. % dash-len gap-len DH -
  280.  
  281. /DH {
  282.     [ 3 1 roll ] 0 setdash
  283. } bind def
  284.  
  285. /SO {
  286.     [] 0 setdash
  287. } bind def
  288.  
  289. /AR /arc load def
  290.  
  291. /TM matrix def
  292.  
  293. /EL {
  294.     TM currentmatrix pop
  295.     translate
  296.     scale newpath 0 0 1 0 360 arc closepath
  297.     TM setmatrix
  298. } bind def
  299.  
  300. /TP {
  301.     1 setlinecap 1 setlinejoin
  302. } bind def
  303.  
  304. systemdict /setpacking known {
  305.     savepacking setpacking
  306. } if
  307.  
  308. end
  309.  
  310.